var ColorHex = new Array('00', '33', '66', '99', 'CC', 'FF')
var SpColorHex = new Array('FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF')
var current = null
function initcolor(id,doc,docId) {
    var colorTable = ''
    for (let i = 0; i < 2; i++) {
        for (let j = 0; j < 6; j++) {
            colorTable = colorTable + '<tr height=15>'
            colorTable = colorTable + '<td width=15 style="background-color:#000000">'
            if (i == 0) {
                colorTable = colorTable + '<td width=15 style="cursor:pointer;background-color:#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '" @click="doclick(this.style.backgroundColor,' + id + ')">'
            }
            else {
                colorTable = colorTable + '<td width=15 style="cursor:pointer;background-color:#' + SpColorHex[j] + '" @click="doclick(this.style.backgroundColor,' + id + ')">'
            }
            colorTable = colorTable + '<td width=15 style="background-color:#000000">'
            for (let k = 0; k < 3; k++) {
                for (let l = 0; l < 6; l++) {
                    colorTable = colorTable + '<td width=15 style="cursor:pointer;background-color:#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '" @click="doclick(this.style.backgroundColor,' + id + ')">'
                }
            }
        }
    }
    colorTable = '<table border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse;width:337px;" bordercolor="000000">'
        + '<tr height=20><td colspan=21 bgcolor=#ffffff style="font:12px tahoma;padding-left:2px;">'
        + '<span style="float:right;padding-right:3px;cursor:pointer;" onclick="colorclose()">×关闭</span>'
        + '</td></table>'
        + '<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" style="cursor:pointer;">'
        + colorTable + '</table>';
        var tid = '';
        if (id == '1') {
            tid = "txtvalue";
        }
        doc.innerHTML = colorTable;
        var current_x = document.getElementById(tid).offsetLeft + 2;
        var current_y = document.getElementById(tid).offsetTop + 20;
        doc.style.left = current_x + "px";
        doc.style.top = current_y + "px";
}
function doclick(obj, id) {
    if (id == '1') {
        document.getElementById("txtvalue").value = obj;
        document.getElementById("txtvalue").style.backgroundColor = obj;
    }
}
function coloropens(id,doc,docId) {
    initcolor(id,doc,docId);
    doc.style.display = "";
}
export{
    coloropens
}